from pydantic_settings import BaseSettings
from typing import Optional, List


class Settings(BaseSettings):
    # 应用基础配置
    APP_NAME: str = "HackPlay API"
    APP_VERSION: str = "1.0.0"
    DEBUG: bool = True
    
    # 数据库配置
    DATABASE_URL: str = "postgresql://hackplay_user:hackplay_pass@localhost:5432/hackplay"
    
    # Supabase 配置
    SUPABASE_URL: Optional[str] = None
    SUPABASE_ANON_KEY: Optional[str] = None
    SUPABASE_SERVICE_ROLE_KEY: Optional[str] = None
    
    # Redis配置
    REDIS_URL: str = "redis://localhost:6379"
    
    # JWT配置
    JWT_SECRET_KEY: str = "your-secret-key-change-in-production"
    JWT_ALGORITHM: str = "HS256"
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    JWT_REFRESH_TOKEN_EXPIRE_DAYS: int = 7
    
    # 文件存储配置
    MINIO_ENDPOINT: str = "localhost:9000"
    MINIO_ACCESS_KEY: str = "hackplay_minio"
    MINIO_SECRET_KEY: str = "hackplay_minio_pass"
    MINIO_BUCKET_NAME: str = "hackplay-files"
    MINIO_SECURE: bool = False
    
    # 文件上传限制
    MAX_FILE_SIZE: int = 100 * 1024 * 1024  # 100MB
    ALLOWED_FILE_TYPES: str = '["jpg", "jpeg", "png", "gif", "pdf", "doc", "docx", "zip", "tar", "gz"]'
    
    # CORS配置
    CORS_ORIGINS: str = '["http://localhost:3000", "http://localhost:3001"]'
    
    # 实时通信配置
    SOCKETIO_CORS_ALLOWED_ORIGINS: str = '["http://localhost:3000", "http://localhost:3001"]'
    
    # 邮件配置
    SMTP_HOST: str = "smtp.gmail.com"
    SMTP_PORT: int = 587
    SMTP_USER: str = "your-email@gmail.com"
    SMTP_PASSWORD: str = "your-app-password"
    SMTP_FROM: str = "your-email@gmail.com"
    
    # 第三方集成
    GITHUB_CLIENT_ID: str = "your-github-client-id"
    GITHUB_CLIENT_SECRET: str = "your-github-client-secret"
    
    # 日志配置
    LOG_LEVEL: str = "INFO"
    
    class Config:
        env_file = ".env"


settings = Settings()